package com.easy.dao;

import com.easy.bean.MonthlySum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface IOrderDao {

    // 查询某个月的入库总金额
    @Select("SELECT COALESCE(SUM(in_sums_price), 0) AS total_in_sums " +
            "FROM in_inventory " +
            "WHERE MONTH(in_date) = #{month} " +
            "AND YEAR(in_date) = #{year} " +
            "AND isdel = 0")
    BigDecimal getInSumsByMonth(@Param("year") int year, @Param("month") int month);

    // 查询某个月的出库总金额
    @Select("SELECT COALESCE(SUM(out_sums_price), 0) AS total_out_sums " +
            "FROM out_inventory " +
            "WHERE MONTH(out_date) = #{month} " +
            "AND YEAR(out_date) = #{year} " +
            "AND isdel = 0")
    BigDecimal getOutSumsByMonth(@Param("year") int year, @Param("month") int month);

    @Select("select count(*) from in_order where isdel=0")
    int countInOrders();
    @Select("select count(*) from out_order where isdel = 0")
    int countOutOrder();
}
